home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / wnos / wn941101 / socket.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-08  |  5.7 KB  |  197 lines

  1. #ifndef    _SOCKET_H
  2. #define    _SOCKET_H
  3.  
  4. #ifndef    _GLOBAL_H
  5. #include "global.h"
  6. #endif
  7.  
  8. #ifdef    ANSIPROTO
  9. #include <stdarg.h>
  10. #endif
  11.  
  12. #ifndef    _MBUF_H
  13. #include "mbuf.h"
  14. #endif
  15.  
  16. #ifndef _PROC_H
  17. #include "proc.h"
  18. #endif
  19.  
  20. /* Local IP wildcard address */
  21. #define    INADDR_ANY        0x0L
  22.  
  23. /* IP protocol numbers */
  24. #define    IPPROTO_ICMP    1
  25. #define    IPPROTO_TCP    6
  26. #define    IPPROTO_UDP    17
  27. #define IPPROTO_AX25    93
  28. #define    IPPROTO_IP    94
  29.  
  30. /* TCP port numbers */
  31. #define    IPPORT_ECHO        7        /* Echo data port */
  32. #define    IPPORT_DISCARD        9        /* Discard data port */
  33. #define    IPPORT_FTPD        20        /* FTP Data port */
  34. #define    IPPORT_FTP        21        /* FTP Control port */
  35. #define IPPORT_TELNET        23        /* Telnet port */
  36. #define IPPORT_SMTP        25        /* Mail port */
  37. #define    IPPORT_FINGER        79        /* Finger port */
  38. #define    IPPORT_TTYLINK        87        /* Chat port */
  39. #define IPPORT_POP2        109        /* POP2 port */
  40. #define IPPORT_POP3        110        /* POP3 port */
  41. #define    IPPORT_NNTP        119        /* Netnews port */
  42. #define IPPORT_RLOGIN        513        /* Remote login */
  43. #define IPPORT_CONVERS        3600        /* Conversd server */
  44. #define IPPORT_XCONVERS     3601        /* compressed convers */
  45.  
  46. /* UDP port numbers */
  47. #define    IPPORT_DOMAIN        53
  48. #define IPPORT_BOOTPS        67
  49. #define IPPORT_BOOTPC       68
  50. #define    IPPORT_RIP        520
  51. #define    IPPORT_REMOTE        1234        /* Pulled out of the air */
  52.  
  53. #define    AF_INET            0
  54. #define    AF_AX25            1
  55. #define AF_NETROM        2
  56. #define    AF_LOCAL        3
  57.  
  58. #define    SOCK_STREAM        0
  59. #define    SOCK_DGRAM        1
  60. #define    SOCK_RAW        2
  61. #define SOCK_SEQPACKET    3
  62.  
  63. /* Socket flag values - controls newline mapping */
  64. #define    SOCK_BINARY        0        /* socket in raw (binary) mode */
  65. #define    SOCK_ASCII        1        /* socket in cooked (newline mapping) mode */
  66. #define    SOCK_QUERY        2        /* Return setting without change */
  67.  
  68. #define    EMFILE            1
  69. #define    EBADF            2
  70. #define    EINVAL            3
  71. #define    ESOCKTNOSUPPORT        4
  72. #define    EAFNOSUPPORT        5
  73. #define    EOPNOTSUPP        6
  74. #define    EFAULT            7
  75. #define    ENOTCONN        8
  76. #define    ECONNREFUSED        9
  77. #define EAFNOSUPP        10
  78. #define    EISCONN            11
  79. #define    EWOULDBLOCK        12
  80. #define    EINTR            13
  81. #define    EADDRINUSE        14
  82. #define    ENOMEM            15
  83. #define EMSGSIZE        16
  84. #define    EALARM            17
  85. #define    EABORT            18
  86.  
  87. /* Berkeley format socket address structures. These things were rather
  88.  * poorly thought out, but compatibility is important (or so they say).
  89.  * Note that all the sockaddr variants must be of the same size, 16 bytes
  90.  * to be specific. Although attempts have been made to account for alignment
  91.  * requirements (notably in sockaddr_ax), porters should check each
  92.  * structure.
  93.  */
  94.  
  95. /* Generic socket address structure */
  96. struct sockaddr {
  97.     short sa_family;
  98.     char sa_data[14];
  99. };
  100.  
  101. /* This is a structure for "historical" reasons (whatever they are) */
  102. struct in_addr {
  103.     unsigned long s_addr;
  104. };
  105.  
  106. /* AX.25 sockaddr stuff */
  107. #define    AXALEN        7
  108.  
  109. /* Number of chars in interface field. The involved definition takes possible
  110.  * alignment requirements into account, since ax25_addr is of an odd size.
  111.  */
  112. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  113.  
  114. /* Socket address, AX.25 style */
  115. struct sockaddr_ax {
  116.     short sax_family;        /* 2 bytes */
  117.     char ax25_addr[AXALEN];
  118.     char iface[ILEN];        /* Interface name */
  119. };
  120.  
  121. /* Socket address, DARPA Internet style */
  122. struct sockaddr_in {
  123.     short sin_family;
  124.     unsigned short sin_port;
  125.     struct in_addr sin_addr;
  126.     char sin_zero[8];
  127. };
  128.  
  129. /* Netrom socket address. */
  130. #ifndef NR4MAXCIRC
  131. struct nr4_addr {
  132.     char user[AXALEN];
  133.     char node[AXALEN];
  134. };
  135. #endif
  136.  
  137. struct sockaddr_nr {
  138.     short nr_family;
  139.     struct nr4_addr nr_addr;
  140. };
  141.  
  142. #define    SOCKSIZE    (sizeof(struct sockaddr))
  143. #define MAXSOCKSIZE    SOCKSIZE /* All sockets are of the same size for now */
  144. extern int32 Ip_addr;
  145.  
  146. /* In socket.c: */
  147. extern int Axi_sock;    /* Socket listening to AX25 (there can be only one) */
  148.  
  149. int accept __ARGS((int s,char *peername,int *peernamelen));
  150. int bind __ARGS((int s,char *name,int namelen));
  151. int close_s __ARGS((int s));
  152. int connect __ARGS((int s,char *peername,int peernamelen));
  153. void freesock __ARGS((struct proc *pp));
  154. int getpeername __ARGS((int s,char *peername,int *peernamelen));
  155. int getsockname __ARGS((int s,char *name,int *namelen));
  156. int listen __ARGS((int s,int backlog));
  157. int recv_mbuf __ARGS((int s,struct mbuf **bpp,int flags,char *from,int *fromlen));
  158. int send_mbuf __ARGS((int s,struct mbuf *bp,int flags,char *to,int tolen));
  159. int setflush __ARGS((int s,int c));
  160. int shutdown __ARGS((int s,int how));
  161. int socket __ARGS((int af,int type,int protocol));
  162. void sockinit __ARGS((void));
  163. int sockkick __ARGS((int s));
  164. int socklen __ARGS((int s,int rtx));
  165. struct proc *sockowner __ARGS((int s,struct proc *newowner));
  166. int usesock __ARGS((int s));
  167. int socketpair __ARGS((int af,int type,int protocol,int sv[]));
  168.  
  169. /* In sockuser.c: */
  170. void flushsocks __ARGS((void));
  171. int keywait __ARGS((char *prompt,int flush));
  172. int recv __ARGS((int s,char *buf,int len,int flags));
  173. int recvchar __ARGS((int s));
  174. int recvfrom __ARGS((int s,char *buf,int len,int flags,char *from,int *fromlen));
  175. int recvline __ARGS((int s,char *buf,unsigned len));
  176. int rrecvchar __ARGS((int s));
  177. int send __ARGS((int s,char *buf,int len,int flags));
  178. int sendto __ARGS((int s,char *buf,int len,int flags,char *to,int tolen));
  179. int seteol __ARGS((int s,char *seq));
  180. int sockmode __ARGS((int s,int mode));
  181. void tflush __ARGS((void));
  182. int tprintf __ARGS((char *fmt,...));
  183. int tputc __ARGS((char c));
  184. int tputs __ARGS((char *s));
  185. int usflush __ARGS((int s));
  186. int usprintf __ARGS((int s,char *fmt,...));
  187. int usputc __ARGS((int s,char c));
  188. int usputs __ARGS((int s,char *x));
  189. int usvprintf __ARGS((int s,char *fmt, va_list args));
  190.  
  191. /* In file sockutil.c: */
  192. char *psocket __ARGS((void *p));
  193. char *sockerr __ARGS((int s));
  194. char *sockstate __ARGS((int s));
  195.  
  196. #endif    /* _SOCKET_H */
  197.